//javascript

function checkAll()
{
	
	var nodeList=document.getElementsByTagName("input");
	for(var i=0;i<nodeList.length;i++)
	{
		if(nodeList[i].className=="checkBox")
		{
			if(document.getElementById("chBAll").checked==true)
			{
				nodeList[i].checked=true;
			}
			else
			{
				nodeList[i].checked=false;
			}
		}
	}
}

function check()
{
	document.getElementById("chBAll").checked=false;
	
}

function delLinkClick(sender,id,text)
{
	var isConfirmed=confirm(text);
	if(isConfirmed==true)
	{
		var name="quantity["+id+"]";
		document.getElementsByName(name)[0].value=0;
		return true;
	}
	else
	{
		return false;
	}
}

function optionalDelele(text)
{
	
	var isConfirmed=confirm(text);
	var nodeList=document.getElementsByTagName("input");
	var isValid=false;
	if(isConfirmed==true)
	{
		for(var i=0;i<nodeList.length;i++)
		{
			if(nodeList[i].className=="checkBox")
			{
				if(nodeList[i].name!="chBAll" && nodeList[i].checked==true)
				{
					var id= nodeList[i].name.substring(3);
					var name="quantity["+id+"]";
					document.getElementsByName(name)[0].value=0;
					isValid=true;
				}
			}
		}
		if(isValid==false)
		{
			alert("You must choose at least one product to do this! Check products you want to delete and try again!");
			return false;
		}
	}
	else
	{
		return false;
	}
}


function addCart(id)
{
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			var count=xmlhttp.responseText;
			if (count=='0')
			{
				document.getElementById("CartModule").innerHTML="empty.";
				document.getElementById("cart_image").src="/images/cart/cartempty.jpg";
			}
			else
			{
				document.getElementById("CartModule").innerHTML=xmlhttp.responseText+" items.";
				document.getElementById("cart_image").src="/images/cart/cartnotempty.jpg";
			}
		}
	}
	xmlhttp.open("GET","/cartsidebar/cartsidebar/index?AddCart="+id,true);
	xmlhttp.send();
}
function addComment(idthing,content,security)
{
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			alert("asdf");
		}
	}
	var link = "?thing_id="+idthing+"&content="+content+"&security_code="+security;
	xmlhttp.open("GET","/commentproduct/jsonpost"+link,true);
	xmlhttp.send();
}


